<template>
	<w-container class='order-list' :class='{batch:currentType==2}'>
		<w-navbar title="" bgColor="#fff">
			<view slot="center" class="pl-24">
				<!-- <view class="order_type_list pa-4 flex">
					<view class="flex-1 text-center order_type_item" :class="{current:orderTypeIndex == index}"
						v-for="(item,index) in orderTypeList" :key="index" @click="changeOrderType(index)">{{item.name}}
					</view>
				</view> -->
				<w-tabs :tabList="orderTypeList" :current="orderTypeIndex" scrollable @change="changeOrderType"></w-tabs>
			</view>
		</w-navbar>

		<!-- 常规订单 -->
		<view v-if="currentOrderType == 'routineTrade'" class="pb-16">
			<view class="bg-color-white">
				<w-tabs scrollable line-width="0" :itemStyle="{padding:'0 10rpx'}" :activeStyle="activeStyle" :current='currenIndex' :tabList="orderMap" :inactiveStyle='inactiveStyle' @change="changOrderStatus"></w-tabs>
			</view>
			
			<view class="order-list-container pa-16" v-if="currentType==1">
				<OrderItem class='mb-12' v-for="item in list" :key="item.order_sn" :order='item'
					@countDownOver='countDownOver'></OrderItem>
			</view>

			<view class="batch-order-list-container plr-16" v-if="currentType==2">
				<PayTypeRadio v-model="batchPayWay" class='mt-8' />
				<BatchOrderList :list='cuurentBatchList' @changeStatus='changeStatus'></BatchOrderList>
			</view>

			<w-loading :type="loading" emptyType="order" emptyTop="100"></w-loading>

			<view class="batch-action bg-color-bottombtn flex flex-js-sb plr-16 pt-14"
				v-if="currentType==2&&list.length">
				<!-- <w-button type="dark" :pain="true" shape="circle" style="width:260rpx"
					@click='showCancel=true'>{{handleLang('取消订单')}}</w-button> -->
				<w-button style="width:100%" type="dark" shape="circle" :disabled="!checkIds.length"
					@click='createPayOrder'>{{handleLang('确认')}}
					<text class="font-size-12" v-if="batchInfo.endtime*1000>this.nowTimestamp">
						{{handleLang(`(${countdown})`)}}
					</text>
				</w-button>
			</view>
		</view>

		<!-- 竞价求购购买 -->
		<view v-if="currentOrderType == 'myBeg'">
			<view class="bg-color-white">
				<w-tabs :scrollable="true" line-width="0" :itemStyle="{padding:'0 10rpx',flexGrow:0}" :activeStyle="activeStyle" :current='currentIndex1':tabList="statusList2"
					:inactiveStyle='inactiveStyle' @change='changeStatus2'></w-tabs>
			</view>
			<view class="pa-16">
				<view class="bg-color-item flex pa-12 br-12 mb-12" v-for="(item,index) in list2" :key="item.id"
					@click="toDetail2(item)">
					<w-image :src='item.goods_image' width="80" height="80" radius="8" mode="aspectFill"></w-image>
					<view class="pl-10 flex-1 flex flex-dir-col flex-js-sb">
						<view class="flex flex-js-sb flex-ai-center">
							<view class="text-overflow font-color-textPrimary" style="max-width: 300rpx;">
								{{item.goods_name && handleLang(item.goods_name)}}
							</view>
							<view class="font-color-textPrimary">
								<text class="font-size-14">￥</text>
								<text class="font-size-20">{{item && item.total_price}}</text>
							</view>
						</view>
						<view class="" v-if="(item.order_status==2|| item.order_status==3)&&item.number>1">
							<u-line-progress inactiveColor='#DEE8FF' style="width: 236rpx;"
								:percentage="(item.sale_number/item.number)*100" activeColor="#222222" :showText='false'
								height="8rpx"></u-line-progress>
							<view class="font-size-10 font-color-999 mt-4">
								{{handleLang('求购数量')}}：{{item.sale_number}}/{{item.number}}
							</view>
						</view>
						<view class="font-size-14 font-color-999" v-else>
							x{{item.number}}
						</view>

						<view class="flex flex-js-sb flex-ai-center">
							<text class="font-size-10 font-color-999">{{item.updatetime|formatDate}}</text>
							<view class="flex">
								<w-button v-if="item.order_status==2" size="mini" pain shape="circle"
									style="font-size: 24rpx;"
									@click.native.stop='cancelOrder2(item,index)'>{{handleLang('取消订单')}}</w-button>
								<w-button v-if="item.order_status==1" size="mini" shape="circle"
									style="font-size: 24rpx;"
									@click.native.stop='pay2(item,index)'>{{handleLang('立即支付')}}</w-button>
								<w-button v-if="item.order_status==4" size="mini" shape="circle"
									style="font-size: 24rpx;"
									@click.native.stop='toBeg2(item)'>{{handleLang('重新求购')}}</w-button>
							</view>
						</view>

					</view>
				</view>
			</view>
			<w-loading :type="loading2" empty-type="search"></w-loading>

		</view>
		<view v-if="currentOrderType == 'compound'" class="compound">
			<view class="item bg-color-item" v-for="(item,idx) in list3" :key="idx" @click="changeShowDetail(item)">
				<w-image :src="item.image" width="83" height="83" radius="10"></w-image>
				<view class="right flex-center-sb">
					<view class="content">
						<text class="font-size-16 font-color-textPrimary font-w-500 mb-4" v-for="(items,idxs) in item.result" :key="idxs">
							<block v-if="items.number>1">{{ handleLang(items.name) }} x{{items.number}}</block>
							<block v-else>{{ handleLang(items.name) }}</block>
						</text>
						<text class="font-size-10 font-color-describe mt-6">{{ item.create_time }}</text>
					</view>
					<w-icon name="arrow-right" size="24" color="#fdfdfd"></w-icon>
				</view>
			</view>
			<w-loading :type="loading3" emptyType="search" emptyTop="100"></w-loading>
			<w-modal v-model="showDetails" :title="handleLang('材料详情')" :showButton="false" :close="true">
				<view class="detailscon mt-16">
					<view class="flex-center-sb mb-12" v-for="(item,idx) in consume" :key="idx">
						<w-image :src="item.image" width="42" height="42" radius="4"></w-image>
						<view class="right flex-center-sb">
							<view>
								<text class="font-size-14 mb-4 font-color-textPrimary font-w-500">{{ handleLang(item.name )}}</text>
								<text class="font-size-10 font-color-describe"># {{ item.collection_code }}/{{item.total_num}}</text>
							</view>
							<text class="font-size-14 font-color-999">{{ handleLang(statusText[item.method]) }}</text>
						</view>
					</view>
				</view>
				<w-button class="btnStyle" @click="toPage">{{handleLang('去查看我的藏品')}}</w-button>
			</w-modal>
		</view>
		<view v-if="currentOrderType == 'consignment'">
			<view class="bg-color-white">
				<w-tabs :tabList="tabList2" scrollable :lineWidth="0" :itemStyle="{padding:'0 10rpx',flexGrow:0}" :activeStyle="activeStyle" :inactiveStyle="inactiveStyle" @change="changeTab2"></w-tabs>
			</view>
			<view class="plr-16 pb-13 mt-10">
				<block v-for="(item,idx) in list3" :key="idx">
					<myConsignmentsItem :item="item" :goods_type="goods_type" @refresh="refresh"></myConsignmentsItem>
				</block>
				<!-- 加载 -->     
				<w-loading :type="loading3" emptyType="search" class="mt-12" emptyTop="100"></w-loading>
			</view>
		</view>
		<view v-if="currentOrderType == 'transfer'" class="transfer">
			<view class="bg-color-white">
				<w-tabs :tabList="tabListzz" scrollable :lineWidth="0" :itemStyle="{padding:'0 10rpx',flexGrow:0}" :activeStyle="activeStyle" :inactiveStyle="inactiveStyle" @change="changezzType"></w-tabs>
			</view>
			<view class="list plr-16">
				<view class="bg-color-item pt-12 plr-12 pb-16 br-12 mb-12" v-for="item in list3" :key="item.id">
					<view class="flex">
						<w-image radius="12" width="83" height="83" :src="item.product.listimg"></w-image>
						<view class="info-bar flex flex-dir-col flex-js-sb" v-if="item.usercollection.types!=1">
							<text class="text-overflow-2 font-size-16 font-color-textPrimary font-w-500" style="width: 100%;">
								{{handleLang(item.product.name)}}
							</text>
							<view class="">
								<text class="font-size-10 font-color-999">编号：#</text>
								<text class="font-size-16 font-color-textPrimary">{{item.usercollection.collection_code}}</text>
								<text class="font-size-10 font-color-999">/{{item.product.total_num}}</text>
							</view>
						</view>
						<view class="info-bar flex flex-ai-center" v-else>
							<text class=" font-size-16 font-color-textPrimary font-w-500">
								{{handleLang(item.product.name)}}
							</text>
						</view>
					</view>
					<view class="font-size-14">
						<view class="mt-16 flex flex-js-sb">
							<text class="font-color-999">{{handleLang(search.types==1? '转赠时间':'转入时间')}}：</text>
							<text class="font-color-textPrimary">{{item.createtime|formatDate}}</text>
						</view>
						<view class="mt-16 flex flex-js-sb">
							<text class="font-color-999">{{handleLang(search.types==1? '接收人':'转赠人')}}：</text>
							<text  class="font-color-textPrimary">{{search.types==1? item.user.mobile:item.from_user.mobile}}</text>
						</view>
					</view>
				</view>
				
				
			</view>
			<w-loading :type="loading3" empty-type="search" empty-top="200"></w-loading>
		</view>
		<w-modal v-model="showCancel" @action='submitCancel'>
			<view class="">
				<view class="text-center ptb-20 font-color-dark font-w-500">
					{{handleLang('您确定要取消该批付订单吗？')}}
				</view>
				<view class="font-size-12">
					{{handleLang('1.取消订单将会限制一段时间使用批量购买功能')}}
				</view>
				<view class="font-size-12">
					{{handleLang('2.累计取消3次将永久限制使用批量购买功能')}}
				</view>
			</view>
		</w-modal>

		<CancelBegOrder v-if="currentOrderIndex2>=0" ref='cancelOrder' :order='list2[currentOrderIndex2]'>
		</CancelBegOrder>
		<PayBegOrder v-if="currentOrderIndex2>=0" ref='payOrder' :order='list2[currentOrderIndex2]'></PayBegOrder>
		<w-toast v-model="showToast" :title="handleLang('温馨提示')" :content="handleLang('您还有未支付订单,是否立即支付')"
			content-align="center" @action='payHasBatchOrder'></w-toast>
	</w-container>
</template>

<script>
	import OrderItem from './components/orderItem.vue'
	import {
		getOderList,
		getBatchOrderList,
		createBatchPayOrder,
		cancelBatchOrder
	} from '@/api/order/index.js'
	import PayTypeRadio from './components/payTypeRadio.vue'
	import BatchOrderList from './components/batchOrderList'
	import myConsignmentsItem from'./components/my-consignments-item.vue';
	import PayUtil from '@/utils/payUtil.js'
	import {
		mapState,
		mapActions
	} from 'vuex'
	import dayjs from 'dayjs'
	import {
		basePayList
	} from '@/config/index.js'
	import {
		entrustOrderList,
		cancelEntrustOrder,
		getMyTradeList
	} from '@/api/trad/index.js'
	import {
		getGiveRecord
	} from '@/api/collection/index.js'
	import { myConsignment } from '@/api/collection/index.js';
	import { recordList } from '@/api/compound/index.js';
	import CancelBegOrder from '@/pages/order/components/CancelBegOrder.vue'
	import PayBegOrder from '@/pages/market/components/PayBegOrder.vue'
	export default {
		components: {
			OrderItem,
			PayTypeRadio,
			BatchOrderList,
			CancelBegOrder,
			PayBegOrder,
			myConsignmentsItem
		},
		data() {
			return {
				showToast: false,
				showCancel: false,
				orderMap: [{
						name: '全部',
						status: 0,
						type: 1
					}, {
						name: '已完成',
						status: 2,
						type: 1
					},
					{
						name: '批量付',
						type: 2,
						status: 0
					},
					{
						name: '待支付',
						status: 1,
						type: 1
					},
					{
						name: '进行中',
						status: 7,
						type: 1
					},
					{
						name: '已取消',
						status: 3,
						type: 1
					},

				],
				loading: 'none',
				inactiveStyle: {
					color: '#999999',
					fontSize: "28rpx",
					backgroundColor:'#F5F5F5',
					borderRadius:'50rpx',
					padding:'8rpx 16rpx',
					fontSize:'20rpx'
				},
				activeStyle: {
					color:'#fff',
					fontWeight:'400',
					backgroundColor:'#1952F8',
					borderRadius:'50rpx',
					padding:'8rpx 16rpx',
					fontSize:'20rpx'
				},
				currentType: 1,
				batchPayWay: 'huifu',
				search: {
					page: 1,
					status: 0,
				},
				list: [],
				batchInfo: {},
				hasBatchOrder: {},
				orderTypeList: [
					{
						name:'常规交易',
						type:'routineTrade'
					},
					{
						name:'求购',
						type:'myBeg'
					},
					{
						name:'合成',
						type:'compound'
					},
					{
						name:'寄售',
						type:'consignment'
					},
					{
						name:'转赠',
						type:'transfer'
					},
				],
				orderTypeIndex: 0,
				// 委托购买
				statusList: [{
						name: "全部",
						status: null
					},
					{
						name: "委托中",
						status: 2
					},
					{
						name: "已成交",
						status: 3
					},
					{
						name: "已取消",
						status: 4
					},
					{
						name: "已退款",
						status: 6
					}
				],
				search1: {
					page: 1,
					status: null
				},
				list1: [],
				loading1: 'none',
				cancelShow: false,
				payShow: false,
				currentOrderIndex1: -1,
				basePayList,
				currentOrderIndex2: -1,
				loading2: 'none',
				statusList2: [{
						name: "全部",
						status: null
					},
					{
						name: "求购中",
						status: 2
					},
					{
						name: "已成交",
						status: 3
					},
					{
						name: "已取消",
						status: 4
					}
				],
				search2: {
					page: 1,
					status: null
				},
				list2: [],
				search3: {
					page: 1,
					status:'',
					goods_type:2,
					type:1
				},
				list3: [],
				loading3:'none',
				consume:{},
				showDetails:false,
				statusText:{
					'10':'销毁',
					'20':'保留',
					'30':'回收'
				},
				tabList2:[
					{ name:'全部',type:'' },
					{ name:'寄售中',type:'1' },
					{ name:'已成交',type:'2' } 
				], 
				tabListzz: [{
					name: '我转赠的',
					type: 1
				}, {
					name: "我收到的",
					type: 2
				}],
			}
		},
		computed: {
			...mapState('config', ['nowTimestamp']),
			currentOrderType(){
				return this.orderTypeList[this.orderTypeIndex].type
			},
			currenIndex() {
				return this.orderMap.findIndex(v => v.status == this.search.status && this.currentType == v.type)
			},
			currentIndex1() {
				return this.statusList.findIndex(v => v.status === this.search1.status)
			},
			currentIndex2() {
				return this.statusList2.findIndex(v => v.status === this.search2.status)
			},
			cuurentBatchList() {
				if (this.currentType == 1) return []
				return this.list.filter(v => {
					return v.income_type.includes(this.batchPayWay)
				})
			},
			checkIds() {
				let list = this.cuurentBatchList.filter(v => v.check).map(v => v.id)
				return list
			},
			countdown() {
				const startTime = dayjs(this.nowTimestamp);
				const endTime = dayjs(this.batchInfo.endtime * 1000);

				const diffInMs = endTime.diff(startTime); // 获取时间差异（毫秒）

				const diffInSeconds = diffInMs / 1000; // 将毫秒转换为秒

				const diffInMinutes = Math.floor(diffInSeconds / 60); // 获取差异的分钟数

				const diffInRemainingSeconds = Math.floor(diffInSeconds % 60); // 获取剩余的秒数	
				return `剩余${diffInMinutes}分${diffInRemainingSeconds}秒`
			}
		},
		onLoad() {
			let orderList = uni.getStorageSync('order-list')
			if (orderList) {
				let {
					type,
					status
				} = orderList;
				this.currentType = type;
				this.search.status = status;
				uni.removeStorageSync('order-list')
			}
			// this.changOrderStatus(this.orderMap[this.currenIndex]);
			this.createNowTimeTimer();
		},
		onShow() {
			this.reflash()
		},
		onPullDownRefresh() {
			this.reflash()
		},
		onReachBottom() {
			this.loadMore()
		},
		methods: {
			...mapActions('config', ['createNowTimeTimer']),
			reflash() {
				if (this.currentOrderType == 'routineTrade') {
					this.changOrderStatus(this.orderMap[this.currenIndex]);
				} else if (this.currentOrderType == 'myBeg') {
					this.loading2 = 'none'
					this.list2 = []
					this.getList2(this.search2)
				}else if(this.currentOrderType == 'compound') {
					this.search3.page = 1
					this.list3 = []
					this.loading3 = 'none'
					this.getCompoundList() //合成
				}else if(this.currentOrderType == 'consignment') {
					this.search3.page = 1
					this.search3.status = ''
					this.list3 = []
					this.loading3 = 'none'
					this.getConsignmentList() //寄售
				}else if(this.currentOrderType == 'transfer') {
					this.search3.page = 1
					this.list3 = []
					this.loading3 = 'none'
					this.search3.status = ''
					this.getTransferList() //转赠
				}
			},
			// 查看
			changeShowDetail(item){
				this.consume = item.consume;
				this.showDetails = true;
			},
			toPage(){
				let isApp=uni.getStorageSync('app')
				if(isApp){
					let isIos = window.localStorage.getItem('ios')
					let action = JSON.stringify({
						action:"gotoActivity",
						params:{
							pageKey:'collection',
						}
					})
					if (isIos) {
						window.webkit.messageHandlers.callbackHandler.postMessage(action);
					} else {
						Android.webCallback(action)
					}
				}else{
					// uni.navigateTo({
					// 	url:'/pages/myCollection/myCollection'
					// })
					uni.switchTab({
						url:"/pages/my/my"
					})
				}
			},
			changeTab2(e){
				this.search3.status = e.type
				this.reflash()
			},
			changezzType(e){
				this.search3.type = e.type 
				this.reflash()
			},
			toBeg2({
				goods_id
			}) {
				uni.navigateTo({
					url: '/pages/market/submitBegBuy?id=' + goods_id
				})
			},
			pay2(item, index) {
				this.currentOrderIndex2 = index;
				this.$nextTick(() => {
					this.$refs.payOrder.pay();
				})
			},
			cancelOrder2(item, index) {
				this.currentOrderIndex2 = index;
				this.$nextTick(() => {
					this.$refs.cancelOrder.cancel();
				})
			},
			toDetail2({
				id
			}) {
				uni.navigateTo({
					url: '/pages/order/beg/info?id=' + id
				})
			},
			cancelOrder(item, index) {
				this.currentOrderIndex1 = index;
				this.cancelShow = true
			},
			pay(item, index) {
				this.currentOrderIndex1 = index;
				this.payShow = true
			},
			toBeg({
				goods_id
			}) {
				uni.navigateTo({
					url: `/pages/market/marketGoodsList?id=${goods_id}&goodsType=2&currentType=2`
				})
			},
			toDetail({
				id
			}) {
				uni.navigateTo({
					url: '/pages/order/entrust/info?id=' + id
				})
			},
			cancelFn(e) {
				if (!e) return this.cancelShow = false
				let orderItem = this.list1[this.currentOrderIndex1]
				if (!orderItem?.id) {
					return uni.showToast({
						title: '订单不存在',
						icon: "none"
					})
				}
				uni.showLoading({
					title: '取消中...'
				})
				cancelEntrustOrder({
					order_id: orderItem.id
				}).then(res => {
					uni.showToast({
						title: res.msg,
						icon: 'success'
					})
					setTimeout(() => {
						this.search1.page = 1
						this.list1 = []
						this.loading1 = 'none'
						this.getList1(this.search1)
					}, 1000)
				})
			},
			submitPay() {
				let orderItem = this.list1[this.currentOrderIndex1]
				new PayUtil({
					pay_type: 4,
					order_number: orderItem?.order_sn,
					order_type: 12,
					pay_way: this.basePayList[0].pay_way,
					order_id: orderItem?.id
				})
			},
			changeOrderType({index}) {
				this.orderTypeIndex = index
				this.reflash()
			},
			submitCancel(res) {
				if (!res) return;
				cancelBatchOrder({
					batch_order_id: this.batchInfo.batch_order_id
				}).then(data => {
					uni.showToast({
						icon: 'success',
						title: "取消成功"
					})
					this.reflash()
				})
			},
			changeStatus(item) {

				item.check = !item.check;
				let index = this.list.findIndex(v => v.id == item.id);
				this.$set(this.list, index, item)
			},
			changeStatus1({
				status
			}) {
				this.search1.status = status;
				this.search1.page = 1
				this.list1 = []
				this.loading1 = 'none'
				this.getList1(this.search1)
			},

			changeStatus2({
				status
			}) {
				this.search2.status = status;
				this.search2.page = 1
				this.list2 = []
				this.loading2 = 'none'
				this.getList2(this.search2)
			},
			countDownOver({
				id
			}) {
				uni.showToast({
					title: '订单超时，已取消',
					icon: 'none'
				})
				let index = this.list.findIndex(v => v.id == id);
				if (this.search.status == 1) {
					this.list.splice(index, 1)
				} else {
					this.$set(this.list[index], 'order_status', 3)
				}
			},
			//
			payHasBatchOrder(e) {
				if (e) {
					this.payBatchOrder(this.hasBatchOrder);
				}
			},
			//创建批付订单
			createPayOrder() {
				createBatchPayOrder({
					order_ids: this.checkIds.join(','),
					batch_order_id: this.batchInfo.batch_order_id,
					pay_way: this.batchPayWay
				}).then(res => {
					if (res.data.order_type) {
						this.showToast = true;
						this.hasBatchOrder = res.data;
					} else {
						this.payBatchOrder(res.data);
					}
				})
			},
			payBatchOrder(data) {
				new PayUtil({
					order_number: data.order_sn,
					order_id: data.order_id,
					order_type: 10,
					pay_way: this.batchPayWay,
					pay_type: 4
				})
			},

			changOrderStatus({
				status,
				type
			}) {
				console.log(type)
				this.currentType = type;
				this.list = []
				this.search.status = status
				this.search.page = 1
				if (type == 1) {
					this.getList(this.search)
				} else {
					this.getBatchList(this.search);
				}

			},
			loadMore() {			
				if (this.currentOrderType == 'routineTrade') {
					if (this.currentType == 2) return;
					let search = this.$tools.copyObj(this.search);
					search.page++
					this.getList(search)
				} else if (this.currentOrderType == 'weituo') {
					let search = this.$tools.copyObj(this.search1)
					search.page++
					this.getList1(search)
				} else if(this.currentOrderType == 'myBeg') {
					let search = this.$tools.copyObj(this.search2)
					search.page++
					this.getList2(search)
				}else if(this.currentOrderType == 'compound') {
					this.getCompoundList() //合成
				}else if(this.currentOrderType == 'consignment') {
					this.getConsignmentList() //寄售
				}else if(this.currentOrderType == 'transfer') {
					this.getTransferList() //转赠
				}
			},
			getList(search) {
				if (this.loading == 'loading') return;
				this.loading = 'loading'
				getOderList(search).then(res => {
					this.loading = 'none'
					if (res.data.total == 0) {
						this.loading = 'empty'
					}
					if (res.data.data.length) {
						res.data.data.map(v => {
							this.$set(this.list, this.list.length, v);
						})
						this.search = search;
					}
				}).finally(() => {
					uni.stopPullDownRefresh()
				})
			},
			getList1(search) {
				if (this.loading1 == 'loading' || this.loading1 == 'nomore') return;
				this.loading1 = 'loading'
				entrustOrderList(search).then(res => {
					uni.stopPullDownRefresh()
					this.loading1 = 'none'
					if (res.data.data.length) {
						this.search1 = search;
					}
					this.list1 = this.list1.concat(res.data.data)
					if (res.data.data.length < res.data.per_page) {
						this.loading1 = 'nomore'
					}
					if (!res.data.total) {
						this.loading1 = 'empty'
					}
				})
			},
			getList2(search) {
				if (this.loading2 == 'loading' || this.loading2 == 'nomore') return;
				this.loading2 = 'loading'
				uni.stopPullDownRefresh()
				getMyTradeList(search).then(res => {

					this.loading2 = 'none'
					if (res.data.data.length) {
						this.search2 = search;
					}
					this.list2 = this.list2.concat(res.data.data)
					if (res.data.data.length < res.data.per_page) {
						this.loading2 = 'nomore'
					}
					if (!res.data.total) {
						this.loading2 = 'empty'
					}
				})
			},
			getBatchList(search) {
				if (this.loading == 'loading') return;
				this.loading = 'loading'
				getBatchOrderList().then(res => {
					this.loading = 'none'
					this.batchInfo = res.data;
					if (res.data.data.length == 0) {
						this.loading = 'empty'
					}
					this.list = res.data.data.map(v => {
						v.check = true
						return v
					})
					this.setBatchFilterPayWay();
				}).finally(() => {
					uni.stopPullDownRefresh()
				})
			},
			//合成
			async getCompoundList(){
				if (this.loading3 == 'loading' || this.loading3 == 'nomore') return;
				this.loading3 = 'loading'
				const { code,data } = await recordList({page:this.search3.page,type:1})
				if(code != 1) return
				uni.stopPullDownRefresh()
				this.list3 = this.list3.concat(data.data)
				this.search3.page = data.current_page
				if(data.total == 0 ) return this.loading3 = 'empty'
				if(data.last_page > data.current_page) {
					this.loading3 = 'none'
					this.search3.page++
				}else {
					this.loading3 = 'nomore'
				}				
			},
			//寄售
			async getConsignmentList(){
				if (this.loading3 == 'loading' || this.loading3 == 'nomore') return;
				this.loading3 = 'loading'
				const { code,data } = await myConsignment(this.search3)
				if(code != 1) return
				uni.stopPullDownRefresh()
				this.list3 = this.list3.concat(data.data)
				this.search3.page = data.current_page
				if(data.total == 0 ) return this.loading3 = 'empty'
				if(data.last_page > data.current_page) {
					this.loading3 = 'none'
					this.search3.page++
				}else {
					this.loading3 = 'nomore'
				}				
			},
			async getTransferList(){
				if (this.loading3 == 'loading' || this.loading3 == 'nomore') return;
				this.loading3 = 'loading'
				const { code,data } = await getGiveRecord({page:this.search3.page,type:this.search3.type})
				if(code != 1) return
				uni.stopPullDownRefresh()
				this.list3 = this.list3.concat(data.data)
				this.search3.page = data.current_page
				if(data.total == 0 ) return this.loading3 = 'empty'
				if(data.last_page > data.current_page) {
					this.loading3 = 'none'
					this.search3.page++
				}else {
					this.loading3 = 'nomore'
				}				
			},
			setBatchFilterPayWay() {
				if (this.list[0]) {
					this.batchPayWay = this.list[0].income_type[0]
				}
			}
		}
	}
</script>

<style lang="scss">
	.batch.order-list {
		padding-bottom: calc(56rpx + 92rpx + env(safe-area-inset-bottom));
	}

	.order_type_list {
		width: 566rpx;

		.order_type_item {
			font-size: 28rpx;
			color: #666;
			padding: 10rpx 0;
			border-radius: 1998rpx 1998rpx 1998rpx 1998rpx;
		}

		.current {
			color: #1952F8;
			font-weight: 500;
			position: relative;

			&::after {
				content: '';
				position: absolute;
				bottom: 0;
				left: 50%;
				transform: translateX(-50%);
				width: 32rpx;
				height: 6rpx;
				background: #1952F8;
				border-radius: 6rpx;
			}
		}
	}

	.order-list {
		/deep/ .u-tabs__wrapper__nav__item {
			// flex-grow: 1;
		}

		/deep/ .u-tabs__wrapper__nav {
			// background-image: url($IMG_URL + '/static/bg/my-bg.png');
			background-size: 100% auto;
			background-position: top;
		}

		&-container {}

		.batch-action {
			position: fixed;
			left: 0;
			bottom: 0;
			width: 750rpx;
			padding-bottom: calc(28rpx + env(safe-area-inset-bottom));
		}
	}

	.batch {
		background: $item-bg-color;
		padding-bottom: calc(14rpx + env(safe-area-inset-bottom));

		.item {
			width: 100%;
			border: 3rpx solid #eee;

			.lable {
				@extend .font-color-999, .font-w-500;
			}
		}

		.price-limit {
			&-inp {
				width: 100rpx;
				@extend .text-center, .mlr-2, .font-w-500, .font-color-main-text;
			}
		}
	}
	.compound {
		padding: 32rpx;
		.item{
			width: 100%;
			padding: 16rpx 26rpx 16rpx 16rpx;
			border-radius: 20rpx;
			@extend .mb-12,.flex-center-sb;
			>.right{
				width: calc(100% - 200rpx);
				@extend .flex-center-sb;
				
				>.content{
					width: 100%;
					min-height: 140rpx;
					@extend .flex,.flex-dir-col,.flex-js-sb;
				}
			}
		}
		.detailscon{
			width: 100%;
			max-height: 40vh;
			overflow-y: scroll;
			
			.right{
				width: calc(100% - 104rpx);
				
				>view{
					width: 80%;
					>text{ display: block; }
				}
			}
		}
		.btnStyle{
			height: 80rpx;
			line-height: 80rpx;
			margin-top: 108rpx;
		}
	}
	.transfer {
	}
</style>